d/run-with-locales: Improve
authorSimon McVittie <smcv@debian.org>
Sun, 1 Mar 2020 20:14:23 +0000 (20:14 +0000)
committerSimon McVittie <smcv@debian.org>
Sun, 1 Mar 2020 20:58:19 +0000 (20:58 +0000)
Gbp-Dch: ignore

debian/rules
debian/run-with-locales
debian/tests/installed-tests

index 3066dea9bbc38a0ada18b391eec4074e555f1de0..52b2afd5df6179669b04bfeb3b0db31d2dc36b02 100755 (executable)
@@ -184,9 +184,9 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
        env -u LD_PRELOAD \
        xvfb-run -a -s "-screen 0 1024x768x24" \
        debian/run-with-locales \
-               --generate de_DE.utf8 \
-               --generate en_GB.utf8 \
-               --generate en_US.utf8 \
+               --generate de_DE.UTF-8 \
+               --generate en_GB.UTF-8 \
+               --generate en_US.UTF-8 \
                --generate sv_SE \
                -- \
        dh_auto_test --builddirectory=debian/build/deb -- -k 0 -j 1 || true
index 8f4aa0208e55bc9c71102c7fecebe8878b47e296..5adb42d15c061e038edfee6606ef99b9a7f55d3e 100755 (executable)
@@ -44,48 +44,64 @@ usage () {
         exec >&2
     fi
 
-    echo "Usage: $me [--generate LOCALE...] COMMAND [ARGS...]"
+    echo "Usage: $me [--generate LOCALE...] [--] COMMAND [ARGS...]"
+    exit "$status"
 }
 
-getopt_temp=+help
+getopt_temp=help
 getopt_temp="$getopt_temp,generate:"
 
-getopt_temp="$(getopt -o '' --long "$getopt_temp" -n "$0" -- "$@")"
+getopt_temp="$(getopt -o '+' --long "$getopt_temp" -n "$0" -- "$@")"
 eval set -- "$getopt_temp"
 unset getopt_temp
 
 generate () {
     local locale="$1"
-    local name
     local charset
+    local source
+    local output
 
-    case "$locale" in
-        (*.utf8)
-            name="${locale%.utf8}"
-            charset=UTF-8
-            ;;
+    echo "$me: $locale..." >&2
 
-        (sv_SE)
-            name="$locale"
-            charset=ISO-8859-1
+    case "$locale" in
+        (*.*)
+            source="${locale%.*}"
+            output="$source.$(
+                export LC_ALL=C
+                printf '%s' "${locale##*.}" | \
+                    tr '[:upper:]' '[:lower:]' | \
+                    tr -d -C '[:lower:][:digit:]'
+            )"
             ;;
 
         (*)
-            echo "$me: Unsupported locale $locale" >&2
-            exit 1
-            ;;
+            source="${locale}"
+            output="${locale}"
     esac
 
-    if [ -e "/usr/lib/locale/$locale/LC_MESSAGES/SYS_LC_MESSAGES" ]; then
+    if [ -e "/usr/lib/locale/$output/LC_MESSAGES/SYS_LC_MESSAGES" ]; then
+        printf '\t%s\n' "Found in locales-all" >&2
         return
     fi
 
+    charset=$(sed -ne "s/^$locale //p" /usr/share/i18n/SUPPORTED)
+
+    if [ -z "$charset" ]; then
+        echo "$me: $locale not found in /usr/share/i18n/SUPPORTED" >&2
+        exit 1
+    fi
+
+    printf '\t%s\n' "Character set: $charset" >&2
+    printf '\t%s\n' "Source file: $source" >&2
+
     if [ -z "$tempdir" ]; then
         tempdir="$(mktemp -d)"
         trap 'rm -fr "$tempdir"' EXIT
     fi
 
-    localedef -i "$name" -f "$charset" "$tempdir/$locale"
+    printf '\t%s\n' "Output: $tempdir/$output" >&2
+
+    localedef -i "$source" -f "$charset" "$tempdir/$output"
 }
 
 while [ "$#" -gt 0 ]; do
index 426a33130a739574b33dd711bd382e8c6b1122b0..83b57ea25e1450514be06845d9c806094d9e383e 100755 (executable)
@@ -14,9 +14,9 @@ export XDG_RUNTIME_DIR="$AUTOPKGTEST_TMP"
 exec dbus-run-session -- \
 xvfb-run -a -s "-screen 0 1024x768x24" \
 debian/run-with-locales \
-    --generate de_DE.utf8 \
-    --generate en_GB.utf8 \
-    --generate en_US.utf8 \
+    --generate de_DE.UTF-8 \
+    --generate en_GB.UTF-8 \
+    --generate en_US.UTF-8 \
     --generate sv_SE \
     -- \
 gnome-desktop-testing-runner \